package com.heima.brhavior.controller.v1;

import com.heima.brhavior.service.ApLikesBehaviorService;
import com.heima.model.behavior.dtos.BehaviorDTO;
import com.heima.model.behavior.dtos.CollectionDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lo
 * @date 2021/9/29
 */
@RestController
@Api(tags = "行为API")
@RequestMapping("/api/v1")
public class ApLikesBehaviorController {

    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;

    @PostMapping("/likes_behavior")
    @ApiOperation("点赞或取消点赞")
    public ResponseResult likeBehavior(@RequestBody @Validated BehaviorDTO likesBehaviorDTO){
        return apLikesBehaviorService.likeBehavior(likesBehaviorDTO);
    }

    @PostMapping("read_behavior")
    @ApiOperation("阅读行为API")
    public ResponseResult readBehavior(@RequestBody @Validated BehaviorDTO readBehaviorDto) {
        return apLikesBehaviorService.readBehavior(readBehaviorDto);
    }

    @PostMapping("un_likes_behavior")
    @ApiOperation("保存或取消 不喜欢行为")
    public ResponseResult unLikeBehavior(@RequestBody @Validated BehaviorDTO unLikesBehaviorDto) {
        return apLikesBehaviorService.unLikeBehavior(unLikesBehaviorDto);
    }


    @PostMapping("collection_behavior")
    @ApiOperation("保存或取消 收藏行为")
    public ResponseResult collectionBehavior(@RequestBody @Validated CollectionDto collectionBehaviorDto) {
        return apLikesBehaviorService.collectionBehavior(collectionBehaviorDto);
    }

    @PostMapping("article/load_article_behavior")
    @ApiOperation("查询文章行为相关信息")
    public ResponseResult loadArticleBehavior(@RequestBody @Validated BehaviorDTO loadArticleBehaviorDto) {
        return apLikesBehaviorService.loadArticleBehavior(loadArticleBehaviorDto);
    }






}
